package cn.csc.module.product.dal.mysql.seachcontext;

import cn.csc.framework.common.pojo.PageResult;
import cn.csc.framework.mybatis.core.mapper.BaseMapperX;
import cn.csc.framework.mybatis.core.query.LambdaQueryWrapperX;
import cn.csc.module.product.controller.admin.seachcontext.vo.SpuSeachContextCreateReqVO;
import cn.csc.module.product.controller.admin.seachcontext.vo.SpuSeachContextExportReqVO;
import cn.csc.module.product.controller.admin.seachcontext.vo.SpuSeachContextPageReqVO;
import cn.csc.module.product.dal.dataobject.seachcontext.SpuSeachContextDO;
import org.apache.ibatis.annotations.Mapper;

import java.math.BigInteger;
import java.util.List;

/**
 * 商品搜索内容 Mapper
 *
 * @author 华南城
 */
@Mapper
public interface SpuSeachContextMapper extends BaseMapperX<SpuSeachContextDO> {

    default PageResult<SpuSeachContextDO> selectPage(SpuSeachContextPageReqVO reqVO) {
        return selectPage(reqVO, new LambdaQueryWrapperX<SpuSeachContextDO>()
                .eqIfPresent(SpuSeachContextDO::getUserId, reqVO.getUserId())
                .eqIfPresent(SpuSeachContextDO::getName, reqVO.getName())
                .betweenIfPresent(SpuSeachContextDO::getCreateTime, reqVO.getCreateTime())
                .orderByDesc(SpuSeachContextDO::getId));
    }

    default List<SpuSeachContextDO> selectList(SpuSeachContextExportReqVO reqVO) {
        return selectList(new LambdaQueryWrapperX<SpuSeachContextDO>()
                .eqIfPresent(SpuSeachContextDO::getUserId, reqVO.getUserId())
                .eqIfPresent(SpuSeachContextDO::getName, reqVO.getName())
                .betweenIfPresent(SpuSeachContextDO::getCreateTime, reqVO.getCreateTime())
                .orderByDesc(SpuSeachContextDO::getId));
    }

    SpuSeachContextDO searchContextByUserId(SpuSeachContextCreateReqVO reqVO);

    List<SpuSeachContextDO> selectContextList(SpuSeachContextCreateReqVO reqVO);

     int deleteContextByUserId(BigInteger userId);

}
